Carbon


StyleRunDirectionProcPtr

Header: QuickdrawText.h Carbon status: Supported

Defines a pointer to a style run direction callback function. Your style run direction callback function is a Boolean function that calculates, for a style run identified by number, the direction of that style run.

typedef Boolean(* StyleRunDirectionProcPtr) (
    SInt16 styleRunIndex, 
    void *dirParam
);

You would declare your function like this if you were to name it MyStyleRunDirectionCallback:

Boolean MyStyleRunDirectionCallback (
    SInt16 styleRunIndex, 
    void *dirParam
);
Parameter descriptions
styleRunIndex

A value that identifies the style run whose direction is needed.

dirParam

A pointer to an application-defined parameter block that contains the font and script information for each style run in the text. The contents of this parameter block are used to determine the direction of the style run. Because of the relationship between the font family ID and the script code, the font family ID can be used to determine the text direction.

function result

A Boolean value that is TRUE for right-to-left text direction, FALSE for left-to-right.

DISCUSSION

To fill the ordering array (type FormatOrder) for style runs on a line, the GetFormatOrder function calls MyStyleRunDirectionCallback for each style run numbered from firstFormat to lastFormat. GetFormatOrder passes MyStyleRunDirectionCallback a number identifying the style run in storage order, and a pointer to the parameter information block, dirParam, that contains the font and style information for the style run. Given dirParam and a style run identifier, the application-defined MyStyleRunDirectionCallback function should be able to determine the style run direction.

You should store your style run information in a way that makes it convenient for MyStyleRunDirectionCallback. One obvious way to do this is to declare a structure type for style runs that allows you to save things like font style, font family ID, script number, and so forth. You then can store these structures in an array. When the time comes for GetFormatOrder to fill the ordering array, MyStyleRunDirectionCallback can consult the style run array for direction information for each of the numbered style runs in turn.

For more information, see GetFormatOrder.

When you provide the Component Manager with a pointer to your function, you should use a universal procedure pointer (UPP). The definition of the UPP data type for your file identification function is as follows:

typedef (StyleRunDirectionProcPtr) StyleRunDirectionUPP;

Before using your style run direction callback function, you must first create a new universal procedure pointer to it, using the NewStyleRunDirectionUPP function, as shown here:

StyleRunDirectionUPP MyStyleRunDirectionUPP;

MyStyleRunDirectionUPP = StyleRunDirectionUPP(&MyStyleRunDirectionCallback);

You then pass MyStyleRunDirectionUPP to the function GetFormatOrder. If you wish to call your own callback function, you can use the InvokeStyleRunDirectionUPP function:

direction = InvokeStyleRunDirectionUPP(styleRunIndex, ¶mInfo, MyStyleRunDirectionUPP);

When you are finished using your callback function, you should dispose of the universal procedure pointer associated with it, using the DisposeStyleRunDirectionUPP function.

DisposeStyleRunDirectionUPP(MyStyleRunDirectionUPP);


© 2000 Apple Computer, Inc. (Last Updated 6/30/2000)